var MAX_SLIDES = 6;
var current_slide = 0;

var oCounter = 0;

var aVisited = new Array( 5 );

function loadCourse()
{
	loadHeader();
	loadNavigation();	
}

function loadHeader()
{
	headerUpdate();
}

function headerNext()
{
	var old_slide = current_slide;
	
	current_slide = ( current_slide + 1 ) % MAX_SLIDES;
	
	var new_slide = current_slide;
	
	navigationUpdateBackground( old_slide, new_slide );
	gotoPage( current_slide );
	headerUpdate();
}

function headerPrev()
{
	var old_slide = current_slide;
	
	current_slide = ( current_slide - 1 ) % MAX_SLIDES;
	if( current_slide < 0 )
		current_slide = 0;
	
	var new_slide = current_slide;
	
	navigationUpdateBackground( old_slide, new_slide );
	gotoPage( current_slide );
	headerUpdate();
}

function gotoPage( slide_number )
{	
	var old_slide = current_slide;
	top.frames[ 'content' ].location.href = 'page' + ( slide_number ) + '.html';
	current_slide = slide_number;
	headerUpdate();
	navigationUpdateBackground( old_slide, current_slide );	
}

function headerUpdate()
{
	top.frames[ 'header' ].document.getElementById( 'slide-current' ).innerHTML = current_slide + 1;
	top.frames[ 'header' ].document.getElementById( 'slide-max' ).innerHTML = MAX_SLIDES;
}

function navigationUpdateBackground( old_slide, new_slide )
{
	var links = top.frames[ 'navigation' ].document.getElementById( 'navigation' ).getElementsByTagName( 'p' );
	var counter = 0;
	var max = links.length;
	
	links[ old_slide ].style.backgroundColor = "#ddddff";
	links[ old_slide ].childNodes[ 0 ].style.color = "#aaaaaa";
	links[ new_slide ].style.backgroundColor = "#ffffff";
	links[ new_slide ].childNodes[ 0 ].style.color = "#000088";
}

function loadNavigation()
{
	gotoPage( 0 );
	navigationUpdateBackground( 0, 0 );
}